package configuration.dataObjects
{
	import common.utils.DateManager;
	
	import mx.collections.ArrayCollection;
	
	public class FilterStatementDO
	{
		public function FilterStatementDO()
		{
		}
		
		public var RECORD_TYPE:String = "";
		public var FILTER_NAME:String = "";
		public var SEQUENCE:Number = 0;
		public var AND_OR:String = "";
		public var ATTRIBUTE:String = "";
		public var OPERAND:String = "";
		public var LITERAL_VALUE:String = "";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var LEFT_PAREN:Number = 0;
		public var RIGHT_PAREN:Number = 0;
		public var OBJECT_ID:Number = 0;
		public var LITERAL_TYPE:String = "Y";

	
		public function Init(xmlObj:XML):void{				
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {			
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
			<FilterStatementDO xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">			
				<RECORD_TYPE>{RECORD_TYPE}</RECORD_TYPE>
				<FILTER_NAME>{FILTER_NAME}</FILTER_NAME>
				<SEQUENCE>{SEQUENCE}</SEQUENCE>
				<AND_OR>{AND_OR}</AND_OR>
				<ATTRIBUTE>{ATTRIBUTE}</ATTRIBUTE>
				<OPERAND>{OPERAND}</OPERAND>
				<LITERAL_VALUE>{LITERAL_VALUE}</LITERAL_VALUE>
				<USER_STAMP>{USER_STAMP}</USER_STAMP>
				<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
				<LEFT_PAREN>{LEFT_PAREN}</LEFT_PAREN>
				<RIGHT_PAREN>{RIGHT_PAREN}</RIGHT_PAREN>
				<OBJECT_ID>{OBJECT_ID}</OBJECT_ID>
				<LITERAL_TYPE>{LITERAL_TYPE}</LITERAL_TYPE>
			</FilterStatementDO>;
			return xmlObj;
		}
		
		public static function getItems(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var itm:FilterStatementDO = new FilterStatementDO();
				itm.Init(xml);
				ac.addItem(itm);
			}
			return ac;
		}
	}
}